package com.unione.map.view.fragment

import android.os.Bundle
import android.text.TextUtils
import android.view.LayoutInflater
import android.view.View
import android.view.View.OnClickListener
import android.view.ViewGroup
import androidx.navigation.Navigation
import com.blankj.utilcode.util.ToastUtils
import com.unione.map.R
import com.unione.map.constant.PageParamConstant
import com.unione.map.databinding.FragmentCreateMapStep3Binding
import com.unione.map.view.act.MainActivity
import com.unione.unione_base.view.BaseFragment

class CreateMapStep3Fragment : AppBaseFragment<FragmentCreateMapStep3Binding>(), OnClickListener {


    private var buildingName: String = ""

    override fun onCreateViewBinding(
        inflater: LayoutInflater,
        parent: ViewGroup?
    ): FragmentCreateMapStep3Binding {
        return FragmentCreateMapStep3Binding.inflate(inflater, parent, false)
    }

    override fun init() {
        buildingName = arguments?.getString(PageParamConstant.KEY_BUILDING_NAME) ?: ""
        initView()
        initListeners()

    }

    private fun initView() {

    }

    private fun initListeners() {
        binding.clVoice.setOnClickListener(this)
        binding.clHome.setOnClickListener(this)
        binding.clBack.setOnClickListener(this)
        binding.btnNext.setOnClickListener(this)
    }

    override fun onClick(v: View?) {
        super.onClick(v)
        if (v == null) return
        val nvController =
            Navigation.findNavController(
                requireActivity() as MainActivity,
                R.id.fragment_container_view
            )
        when (v.id) {
            R.id.btnNext -> {
                val floorName = binding.etFloorNo.text.toString().trim()
                if (TextUtils.isEmpty(floorName)) {
                    ToastUtils.showLong(getString(R.string.pls_input_your_current_floor))
                    return
                }
                val bundle = Bundle()
                bundle.putString(PageParamConstant.KEY_BUILDING_NAME, buildingName)
                bundle.putString(PageParamConstant.KEY_FLOOR_NAME, floorName)
                nvController.navigate(R.id.createMapStep4Fragment, bundle)
            }
        }
    }
}